<template>
  <!--新增黑名单-->
  <div class="ziliao">
    <wv-group title="黑名单手机号">
      <wv-input placeholder="请输入手机号" v-model="black.mobile" type="number" :maxlength="11"></wv-input>
    </wv-group>
    <wv-group title="证件号">
      <wv-input placeholder="请输入证件号" v-model="black.identityNo"></wv-input>
    </wv-group>
    <wv-group class="textarea">
      <wv-textarea placeholder="原因" :rows="5" :max-length="1000" v-model="black.blackDesc"></wv-textarea>
    </wv-group>
    <p class="offer" @click="goSubmitBlack(black)">保存</p>
  </div>
</template>

<script type="text/ecmascript-6">
  import {employeeAddBlack} from '../../../test/unit/http'
  import {Toast} from 'we-vue'

  export default {
    name: 'addblack',
    props: {},
    data() {
      return {
        src: require('../../assets/arrow.png'),
        img: require('../../assets/close.png'),
        pic: require('../../assets/right.png'),
        black: {},
      };
    },
    methods: {
      checkFrom: function (black) {
        let msg = {};
        let tag = true;
        if (this.$myUtils.isNull(black.mobile)) {
          tag = false
        }
        if (this.$myUtils.isNull(black.identityNo)) {
          tag = false
        }
        if (!tag) {
          msg['result'] = false;
          msg['info'] = '手机号或证件号必须填一个';
          return msg;
        }
        msg['result'] = true;
        msg['info'] = '校验成功';
        return msg;
      },
      goSubmitBlack(black) {
        let checkResult = this.checkFrom(black);
        console.log(checkResult);
        if (!checkResult.result) {
          Toast.text(checkResult.info);
          return;
        }
        employeeAddBlack(black).then(res => {
          if (res.code == 100) {
            this.$router.push('black');
          } else {
            Toast.text(res.info)
          }
        })

      }
    },
    created() {
    },
    components: {}
  }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="less" rel="stylesheet/less">

  .offer {
    position: fixed;
    bottom: 0;
    width: 100%;
    background-image: linear-gradient(to left, #f98e3c, #f98e3c);
    height: 50px;
    line-height: 50px;
    color: #fff;
    text-align: center;
    z-index: 999;
  }

</style>
